package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DeleteDao {
    public boolean deleteDao(String sName) {
        PreparedStatement preparedStatement = null;
        Connection connection = null;
        ResultSet resultSet = null;
        try {
            connection = DBConnection.getConnection();
            preparedStatement = connection.prepareStatement("select d_name from discs where d_name=?");
            preparedStatement.setString(1, sName);
            resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) {
                preparedStatement=connection.prepareStatement("delete from discs where d_name=?");
                preparedStatement.setString(1,sName);
                preparedStatement.executeUpdate();
                return true;
            }
        } catch (Exception e) {
            System.out.println("异常");
            return false;
        }finally {
            DBConnection.release(connection,preparedStatement,resultSet);
        }
        return false;
    }
}
